<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="xdz" uri="/xdztools" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${xdz:domain() }/css/bootstrap.min.css">
<link rel="stylesheet" href="${xdz:domain() }/css/font-awesome.min.css">
<%-- <link rel="stylesheet" href="${xdz:domain() }/css/style.min.css"> --%>
<link rel="stylesheet" href="${xdz:domain() }/css/kkpager_blue.css">
<link rel="stylesheet" href="${xdz:domain() }/css/jquery.treetable.theme.default.css?v=1" />
<link rel="stylesheet" href="${xdz:domain() }/css/jquery.treetable.css?v=1" />
</head>
<body>
    <form action="../systemRoleMenu/list" id="systemRoleMenuBaseForm" method="post">
		<div class="panel panel-default">
			<header class="panel-heading"><h3 class="panel-title"> ${tableName }</h3></header>
			<div class="panel-body">
				<div class="row">
					<input type="hidden" name="roleId" value="${roleId }">
<!-- 					<div class="col-md-2"> -->
<%-- 						<input type="text" class="form-control input-sm" placeholder="菜单名" name="menuName" value="${condition.menuName }"> --%>
<!-- 					</div> -->
<!-- 					<div class="col-md-2"> -->
<!-- 						<button class="btn btn-primary btn-sm" type="submit">查询</button> -->
<!-- 					</div> -->
					<div class="col-md-2 pull-right">
						<button class="btn btn-primary btn-sm pull-right" type="button" onclick="javascript:history.go(-1)">返回</button>
					</div>
				</div>
			</div>
			<div class="table-responsive scroll-wrapper">
				<table class="table table-striped  table-hover table-condensed treetable" id="treeTable1">
                   <thead>
                       <tr>
                           <th>菜单名</th>
                           <th>查询</th>
                           <th>新增</th>
                           <th>修改</th>
                           <th>删除</th>
                       </tr>
                   </thead>
                   <tbody>
                       <c:forEach var="list" items="${list }">
							<tr data-tt-id="${list.menuId }" <c:if test="${list.parentId != 0 }">data-tt-parent-id="${list.parentId}"</c:if>>
								<td>
									<span <c:choose>
										 	<c:when test="${list.parentId==0 }">class="folder"</c:when>
										 	<c:otherwise>class="file"</c:otherwise>
										</c:choose>>${list.menuName }</span>
								</td>
								<c:choose>
									<c:when test="${list.parentId == 0 }">
										<td></td>
										<td></td>
										<td></td>
										<td></td>
									</c:when>
									<c:otherwise>
		                              	<td>
		                           			<input type="checkbox" data-id="${list.menuId }" data-right="rselect" class="rightcheck" id="rselect${list.menuId }" <c:if test="${list.rselect==1 }">checked="checked"</c:if>><label for="rselect${list.menuId }">查询</label>
		                              	</td>
		                              	<td>
		                           			<input type="checkbox" data-id="${list.menuId }" data-right="radd" class="rightcheck" id="radd${list.menuId }" <c:if test="${list.radd==1 }">checked="checked"</c:if>><label for="radd${list.menuId }">新增</label>
		                              	</td>
		                              	<td>
		                           			<input type="checkbox" data-id="${list.menuId }" data-right="rupdate" class="rightcheck" id="rupdate${list.menuId }" <c:if test="${list.rupdate==1 }">checked="checked"</c:if>><label for="rupdate${list.menuId }">修改</label>
		                              	</td>
		                              	<td>
		                           			<input type="checkbox" data-id="${list.menuId }" data-right="rdelete" class="rightcheck" id="rdelete${list.menuId }" <c:if test="${list.rdelete==1 }">checked="checked"</c:if>><label for="rdelete${list.menuId }">删除</label>
		                              	</td>
									</c:otherwise>
								</c:choose>
							</tr>
                       </c:forEach>
                   </tbody>
               	</table>
            </div>
        </div>
    </form>
   <script src="${xdz:domain() }/js/jquery.min.js"></script>
    <script src="${xdz:domain() }/js/jquery.treetable.js"></script>
    <script src="${xdz:domain() }/js/bootstrap.min.js"></script>
    <script src="${xdz:domain() }/js/plugins/fuelux/fuelux.js"></script>
    <script src="${xdz:domain() }/js/underscore-min.js"></script>
    <script src="${xdz:domain() }/js/plugins/dataTables/jquery.dataTables.js"></script>
    <script src="${xdz:domain() }/js/app.js"></script>
    <script src="${xdz:domain() }/js/app.plugin.js"></script>
    <script src="${xdz:domain() }/js/app.data.js"></script>
    <script src="${xdz:domain() }/js/pagination.js"></script>
    <script type="text/javascript" src="${xdz:domain() }/js/plugins/layer/layer.min.js"></script>
    <script>
    $(function(){
        $('#treeTable1').treetable({
        	expandable: true,
        	clickableNodeNames: true
        	});
    });
    $(".rightcheck").on("click", function(e){
		$.ajax({
			url : "../systemRoleMenu/setRight",
			type : 'POST',
			data : {
				roleId : '${roleId}',
				menuId : $(this).data("id"),
				right : $(this).data("right"),
				checked : this.checked
			},
			dataType : 'text',
			async : false,
			success : function(data, status) {
			},
			error : function(e) {
				layer.msg("设置失败:" + e.status + ", " + e.statusText);
				this.checked = !this.checked;
			}
		});
    });
    </script>
</body>
</html>
